//轮播图
var oBox = document.getElementById("box");
var oUl = document.getElementById("inner-box");
var oLeft = document.getElementById("left");
var oRight = document.getElementById("right");
var cur = 0;
var target = 0;
var timer1 = null;
    
    function sport(tar) {
        clearInterval(timer1);
        timer1 = setInterval(autoPlay, 30);
        function autoPlay() {
            if (cur == tar) {
                clearInterval(timer1)
            } else {
                speed = (tar - cur) / 7;
                speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
                cur = cur + speed;
                oUl.style.left = cur + "%";
            }
        }
    }

    oRight.onclick = function () {
        if (target <= -400) {
            cur = 0;
            target = -100;
        } else {
            target -= 100;
        }
        sport(target);
    }

    oLeft.onclick = function () {
        if (target > -100) {
            cur -= 400;
            target = -300;
        } else {
            target += 100;
        }
        sport(target);
    }

//联系方式
var inputs = document.querySelectorAll(".contact-list input");
var lis = document.querySelectorAll(".contact-alert li");
var btn = document.querySelector(".contact-btn");

btn.onclick = function () {
    var v1 = inputs[0].value;
    var v2 = inputs[1].value;
    var v3 = inputs[2].value;
    var v4 = inputs[3].value;
    if (v1 == "") {
        lis[0].style.display = "block";
    } else if (v2 == "") {
        lis[1].style.display = "block";
    } else if (v3 = "") {
        lis[2].style.display = "block";
    } else if (v4 == "") {
        lis[3].style.display = "block";
    } else {
        lis[4].style.display = "block";
    }
}

for (var i = 0; i < inputs.length; i++) {
    inputs[i].onclick = function () {
        for (var i = 0; i < lis.length; i++) {
            lis[i].style.display = "none";
        }
    }
}